import axios from 'axios'
import url from './config.js'
import timeout from './timeout.js'

const errMsg='请求不到'
export default {
	information(){
		return new Promise((resolve,reject)=>{
			axios.post(`${url}/users/information`)
			.then((result)=>{
				var res=result.data;
				if (res.status==1) {
					resolve(res)
				}else {
					reject(res.msg)
				}
			})
			.catch((err) => {
				console.log(err)
				reject(errMsg)
			})
			timeout(reject)
		})
	},
	campus(){
		return new Promise((resolve,reject)=>{
			axios.post(`${url}/users/campus`)
			.then((result)=>{
				var res=result.data;
				if (res.status==1) {
					resolve(res)
				}else {
					reject(res.msg)
				}
			})
			.catch((err) => {
				console.log(err)
				reject(errMsg)
			})
			timeout(reject)
		})
	},
	department(){
		return new Promise((resolve,reject)=>{
			axios.post(`${url}/users/department`)
			.then((result)=>{
				var res=result.data;
				if (res.status==1) {
					resolve(res)
				}else {
					reject(res.msg)
				}
			})
			.catch((err) => {
				console.log(err)
				reject(errMsg)
			})
			timeout(reject)
		})
	},

}